Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 15, 2025

Automatically close issues labeled “Needs Author Feedback” after 7 days of inactivity to keep the backlog current.

  • New workflow: Scheduled (daily, 09:00 UTC) and manual workflow scans open issues with the label, posts a notice, and closes them when inactive for 7+ days.
  • Safety: PRs are skipped; comment must succeed before closure; errors are logged without silently closing.

Example (workflow snippet):

on:
  schedule:
    - cron: "0 9 * * *"
  workflow_dispatch: {}

jobs:
  close-inactive:
    steps:
      - uses: actions/github-script@v7
        with:
          script: |
            // posts notice, then closes issues inactive for 7 days
Original prompt

write pipeline of GitHub Actions + scheduled workflow 自动关闭“Needs Author Feedback”且 7 天无回复的 issue


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add GitHub Actions workflow to auto-close issues Add scheduled auto-closure for stale “Needs Author Feedback” issues Dec 15, 2025
Copilot AI requested a review from YunchuWang December 15, 2025 20:19
@torosent torosent marked this pull request as ready for review December 15, 2025 21:34
Copilot AI review requested due to automatic review settings December 15, 2025 21:34
@torosent torosent merged commit b95a9ad into main Dec 15, 2025
9 checks passed
@torosent torosent deleted the copilot/add-auto-close-needs-feedback-issues branch December 15, 2025 21:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a GitHub Actions workflow to automatically close issues labeled "Needs Author Feedback" after 7 days of inactivity. However, the repository already has an existing GitOps policy (.github/policies/resourceManagement.yml) that performs the same function with the label "Needs: Author Feedback" (note the colon). The new workflow creates duplication and uses an inconsistent label format that won't match existing issues.

Key Changes

  • Adds scheduled daily workflow (09:00 UTC) with manual trigger support
  • Implements 7-day inactivity check and automatic closure with comment notification
  • Includes error handling for comment creation and issue closure operations

Comment on lines +1 to +63
name: Close inactive author feedback issues

on:
schedule:
- cron: "0 9 * * *"
workflow_dispatch:

permissions:
contents: read
issues: write

jobs:
close-inactive:
runs-on: ubuntu-latest
steps:
- name: Close issues waiting on author feedback
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const label = "Needs Author Feedback";
const daysInactive = 7;
const cutoff = new Date(Date.now() - daysInactive * 24 * 60 * 60 * 1000);

const { owner, repo } = context.repo;
const issues = await github.paginate(github.rest.issues.listForRepo, {
owner,
repo,
state: "open",
labels: label,
per_page: 100,
sort: "updated",
direction: "asc",
});

for (const issue of issues) {
if (issue.pull_request) {
continue;
}

const updatedAt = new Date(issue.updated_at);
if (updatedAt > cutoff) {
continue;
}

const body = [
"We haven't heard back in 7 days, so we're automatically closing this issue.",
"If you still need help, please reply and we can reopen it."
].join("\n\n");

try {
await github.rest.issues.createComment({ owner, repo, issue_number: issue.number, body });
} catch (error) {
console.warn(`Skipping issue #${issue.number} because of an error while adding the notice: ${error}`);
continue;
}

try {
await github.rest.issues.update({ owner, repo, issue_number: issue.number, state: "closed" });
} catch (error) {
console.warn(`Skipping issue #${issue.number} because of an error while processing closure: ${error}`);
}
}
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow duplicates functionality already handled by the existing GitOps policy in .github/policies/resourceManagement.yml (lines 11-43). The existing policy already closes issues with "Needs: Author Feedback" label after 7 days of inactivity (4 days for warning + 3 days to close). Having two separate systems managing the same process creates potential conflicts, confusion, and maintenance overhead. Consider whether this workflow is necessary, or if the existing policy should be modified instead.

Suggested change
name: Close inactive author feedback issues
on:
schedule:
- cron: "0 9 * * *"
workflow_dispatch:
permissions:
contents: read
issues: write
jobs:
close-inactive:
runs-on: ubuntu-latest
steps:
- name: Close issues waiting on author feedback
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const label = "Needs Author Feedback";
const daysInactive = 7;
const cutoff = new Date(Date.now() - daysInactive * 24 * 60 * 60 * 1000);
const { owner, repo } = context.repo;
const issues = await github.paginate(github.rest.issues.listForRepo, {
owner,
repo,
state: "open",
labels: label,
per_page: 100,
sort: "updated",
direction: "asc",
});
for (const issue of issues) {
if (issue.pull_request) {
continue;
}
const updatedAt = new Date(issue.updated_at);
if (updatedAt > cutoff) {
continue;
}
const body = [
"We haven't heard back in 7 days, so we're automatically closing this issue.",
"If you still need help, please reply and we can reopen it."
].join("\n\n");
try {
await github.rest.issues.createComment({ owner, repo, issue_number: issue.number, body });
} catch (error) {
console.warn(`Skipping issue #${issue.number} because of an error while adding the notice: ${error}`);
continue;
}
try {
await github.rest.issues.update({ owner, repo, issue_number: issue.number, state: "closed" });
} catch (error) {
console.warn(`Skipping issue #${issue.number} because of an error while processing closure: ${error}`);
}
}
# (File deleted)

Copilot uses AI. Check for mistakes.
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const label = "Needs Author Feedback";
const daysInactive = 7;
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 7-day inactivity period conflicts with the existing policy timing. The current resourceManagement.yml policy uses a 7-day total process: adds a warning comment after 4 days of inactivity, then closes after 3 more days. This provides users with advance notice. The new workflow closes issues immediately after 7 days without prior warning. Consider aligning with the existing two-stage approach to provide better user experience, or clearly document why a different approach is needed.

Copilot uses AI. Check for mistakes.
Comment on lines +47 to +48
"We haven't heard back in 7 days, so we're automatically closing this issue.",
"If you still need help, please reply and we can reopen it."
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The closing message should match the established tone and format used in the existing policy. The current resourceManagement.yml uses a more formal message structure that includes markdown formatting for emphasis. Consider using a message consistent with the existing policy's style.

Suggested change
"We haven't heard back in 7 days, so we're automatically closing this issue.",
"If you still need help, please reply and we can reopen it."
"**This issue has been automatically closed due to lack of author feedback after 7 days.**",
"",
"If you still require assistance, please comment on this issue and we will be happy to reopen it."

Copilot uses AI. Check for mistakes.
labels: label,
per_page: 100,
sort: "updated",
direction: "asc",
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow retrieves all open issues with the label and filters them in memory. For repositories with many issues, this could be inefficient. Consider adding the 'since' parameter to the API call to filter issues at the API level based on the cutoff date, reducing the amount of data transferred and processed.

Suggested change
direction: "asc",
direction: "asc",
since: cutoff.toISOString(),

Copilot uses AI. Check for mistakes.
on:
schedule:
- cron: "0 9 * * *"
workflow_dispatch:
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow_dispatch trigger should have empty braces for consistency with the codeQL.yml workflow in this repository (line 15), which uses explicit empty object notation. Update to 'workflow_dispatch: {}' for consistency.

Suggested change
workflow_dispatch:
workflow_dispatch: {}

Copilot uses AI. Check for mistakes.
Comment on lines +58 to +62
try {
await github.rest.issues.update({ owner, repo, issue_number: issue.number, state: "closed" });
} catch (error) {
console.warn(`Skipping issue #${issue.number} because of an error while processing closure: ${error}`);
}
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the issue closure fails but the comment was successfully posted, the issue will remain open with a closure notice that's inaccurate. The existing resourceManagement.yml policy handles this atomically through its action system. Consider adding a state check or removing the comment if closure fails to maintain consistency between the comment message and actual issue state.

Copilot uses AI. Check for mistakes.
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const label = "Needs Author Feedback";
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The label "Needs Author Feedback" does not match the existing label format used in the repository. The existing policy in .github/policies/resourceManagement.yml uses "Needs: Author Feedback" (with a colon). This inconsistency means the workflow will target different issues than intended. Update the label to match the existing convention: "Needs: Author Feedback".

Suggested change
const label = "Needs Author Feedback";
const label = "Needs: Author Feedback";

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants